package offer;
@FunctionalInterface
public interface ConvertToTitle {
    String convertToTitle(int columnNumber);
}
class ConvertToTitleImpl1 implements ConvertToTitle{
    static final int TEST_03 = 28;
    static final int TEST_01 = 701;
    static final int TEST_02 = 1;
    public static void main(String[] args) {
        new ConvertToTitleImpl1().convertToTitle(TEST_03);

    }
    static final int BASE = 26;
    static final char[] CHAR_MAP = new char[]{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

    @Override
    public String convertToTitle(int columnNumber) {
        StringBuilder ans = new StringBuilder();

        while(columnNumber != 0){
            columnNumber--;
            ans.append(CHAR_MAP[columnNumber % BASE]);
            columnNumber /= BASE;
        }
        return ans.reverse().toString();

        /*
        while(columnNumber != 0){
            int temp = columnNumber % BASE;
            ans.insert(0,CHAR_MAP[temp - 1]);
            columnNumber += 1 ;
            columnNumber /= BASE ;
            if(columnNumber < BASE + 1){
                break;
            }
        }

         */
    }
}
